<?php

class Admini_BannerController extends Uuch_ManageController {
   
    public function init() {
        parent::init();
        $this->appendCss('/admins/css/yundan.css');
        $this->appendCss('/admins/css/common.css');
        $this->appendScript('/admins/js/jquery/jquery-1.7.2.min.js')->appendScript('/js/jquery.validate.min.js')->appendScript('/js/messages_cn.js')->appendScript('/js/uuch.js');
        $this->setTitle("轮播管理");
        $this->view->type = "general";
    }    

    public function indexAction()
    {
        $this->appendScript('/admins/js/jquery.form.js');
        $banner = Application_Model_Banner::getAll(array('status'=>1));        
        $this->view->banner = $banner;
        $this->view->stype = 6;
    }

    public function gonggaoAction()
    {
        $banner = Application_Model_Banner::getgonggao();        
        if($this->isPost()){           
            $gonggao['title'] = $this->getSafeParam("title");            
            $gonggao['url'] = trim($this->_getParam("url"));
            $gonggao['order']= $this->_getParam("order");
            $gonggao['status'] = 2;              
            Application_Model_Banner::editgonggao($gonggao); 
           $this->view->ok = 1;    
        }
        $this->view->banner = $banner;
        $this->view->stype = 7;
    }

       public function addbannerAction()
    {
        $banner['id']= $this->getSafeParam("id");
        $banner['title'] = $this->getSafeParam("title");
        $banner['picurl'] = $this->getSafeParam("picurl");
        $banner['url'] = $this->getSafeParam("url");
        $banner['order']=$this->getSafeParam("order");
        $banner['status']=$this->getSafeParam("status");    
        $navigationId = Application_Model_Banner::add($banner);       
        if($navigationId != ""){
            $this->json(1);
        } else {
            $this->json(0);
        }
    }
     public function detailAction()
    {
        $id = $this->getSafeParam("id");
        $navigationItem = Application_Model_Banner::load($id);
        if($navigationItem != null){
            $this->json(array("sj"=>1,"title"=>$navigationItem->title,"picurl"=>$navigationItem->picurl,"status"=>$navigationItem->Status,"order"=>$navigationItem->Order,"url"=>$navigationItem->url));
        } else {
            $this->json(array("sj"=>0));
        }
    }
}
